package com.platform.common.utils;

import javax.servlet.http.HttpServletRequest;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

public class ParamUtils {

    public static String getParamToString(HttpServletRequest request) {

        String param = "";
        Map map = request.getParameterMap();
        Set keSet = map.entrySet();
        for(Iterator itr = keSet.iterator(); itr.hasNext();){
            Map.Entry me = (Map.Entry)itr.next();
            Object ok = me.getKey();
            Object ov = me.getValue();
            String values = "";
            if(ov instanceof String[]){
                String[] value = (String[])ov;
                for(int i=0;i<value.length;i++){
                    values += value[i] + ",";
                }
                values = values.substring(0,values.length()-1);
            }else{
                values = ov.toString();
            }
            param += "&" + ok + "=" + values;
        }
        if(param.length() > 0) {
            param = param.substring(1,param.length());
        }
        return param;
    }

}
